const express=require("express");
const path = require('path');  
const bodyParser=require("body-parser");
const cors = require('cors');  //跨域
const router=require("./router/router.js")
const articleRouter=require("./router/articleRouter.js")
const bookRouter=require("./router/bookRouter.js")
const starRouter=require("./router/starRouter.js")
const videoRouter=require("./router/videoRouter.js")

const app=express();

app.use(cors())
app.use(bodyParser.urlencoded({extended:false}));
app.use(bodyParser.json());
app.use('/',router)
app.use('/article',articleRouter)
app.use('/book',bookRouter)
app.use('/star',starRouter)
app.use('/video',videoRouter)
app.use(express.static(path.join(__dirname, 'public')));  

const port=process.env.PORT || 5000;
app.listen(port,()=>{
    console.log(`server running on port ${port}`)
})